﻿# 仅抓 mobile：数字+字母序列号
# 获取所有已连接的设备
$devices = adb devices | Where-Object { $_ -match '^(\S+)\s+device$' -and $_ -notmatch 'emulator' } | ForEach-Object { $Matches[1] }

# 筛选同时包含数字和字母的设备序列号（mobile设备）
$mobileDevices = $devices | Where-Object { $_ -match '^[0-9A-Za-z]+$' -and ($_ -match '[0-9]') -and ($_ -match '[a-zA-Z]') }

if (-not $mobileDevices -or $mobileDevices.Length -eq 0) { Write-Error "❌ 找不到同时包含数字和字母的设备序列号（mobile）"; exit 1 }

Write-Host "筛选出的 glass 设备：$mobileDevices"

$dev = $mobileDevices
Write-Host "✅ mobile 设备 → $dev"

# 使用Windows批处理文件运行gradle命令
./gradlew.bat :mobile-app:installDebug
adb -s $dev shell am start -n com.maint.m/.TicketListActivity